<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!--<div style="font-size: 30px;">登录中。。。</div>-->
    <!--<div id="code"></div>-->
    <!--<div id="to_path"></div>-->
    <!--<div id="res"></div>-->
    <!--<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>-->
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js"></script>

    <script>
      let arr = location.search.slice(1).split('&')
      let o = {}
      arr.forEach((item) => {
        let _arr = item.split('=')
        let k = _arr[0]
        o[k] = _arr[1]
      })
      const openid = o.state
      // $('#code').html(o.code)
      // $('#to_path').html(o.to_path)
      axios({
        // url: 'http://localhost/login',
        // url: 'https://springboot-xg9i-79717-6-1322190481.sh.run.tcloudbase.com/login',
        url: 'https://tiku.tibangbang.cn/2c/wxLogin',
        params: {
          code: o.code,
          openid,
        },
      })
        .then((res) => {
          if (res.data && res.data.code === 200) {
            const url = decodeURIComponent(o.to_path + '?openid=' + openid)
            window.location.replace(url)
          }

          // $('#res').html(JSON.stringify(res))
          // if (url.indexOf('?') === -1) {
          //     location.replace(url + "?token=" + res.data.token)
          // } else {
          //     location.replace(url + "&token=" + res.data.token)
          // }
        })
        .catch((err) => {
          // alert(err)
        })
    </script>
  </body>
</html>
